package org.wejob.web.buffer;

import org.wejob.web.api.BufferNode;
import org.wejob.web.api.QueueNode;

import java.nio.Buffer;

public class AbstractBuffer<V extends Buffer> implements BufferNode<V> {
    private AbstractBuffer pre;
    private AbstractBuffer next;
    private V buffer;

    public boolean isEmpty() {
        if (this.buffer == null)
            return true;
        return !this.buffer.hasRemaining();
    }

    @Override
    public AbstractBuffer pre() {
        return this.pre;
    }

    @Override
    public void setPre(QueueNode p) {
        this.pre = (AbstractBuffer) p;
    }

    @Override
    public QueueNode next() {
        return (AbstractBuffer) this.next;
    }

    @Override
    public void setNext(QueueNode n) {
        this.next = (AbstractBuffer) n;
    }

    @Override
    public V getVal() {
        return this.buffer;
    }

    @Override
    public void setVal(V val) {
        this.buffer = val;
    }

}
